Jednacine
clear variables
syms C L L1 L12 L2 R U a DiL1 DiL2 DuC i iL1 iL2 iR u uC uL1 uR t ug
assume(0 < R & 0 < C & 0 < L1 & 0 < L2 & 0 < L12 & 0 < L & 0 < U & 0 < a)
zamene = [L1 == L, L2 == L, L12 == L]
zamene = 
pobuda = ug == U*exp(-(a*t))*heaviside(t)
pobuda = 
jednacine = [ug == uR + uL1,...
uR == R * iR,...
uL1 == L1 * DiL1 + L12 * DiL2,...
u == L2 * DiL2 + L12 * DiL1,...
uC == uL1 - u,...
i == C * DuC,...
iR == i + iL1,...
i == iL2]
jednacine = 
promenljive = [uL1, u, uR, iR, i]
promenljive = 
Jednacine izvoda
jednacineIzvoda = eliminate(jednacine, promenljive)
jednacineIzvoda = 
JednacineIzvodaZamene = subs(jednacineIzvoda, lhs(zamene), rhs(zamene))
JednacineIzvodaZamene = 
syms iL1(t) uC(t) iL2(t)
PromenljiveStanjaIzvodi = [uC == uC(t), DuC == diff(uC(t)), iL1 == iL1(t), DiL1 == diff(iL1(t)), iL2 == iL2(t), DiL2 == diff(iL2(t))]
PromenljiveStanjaIzvodi(t) = 
JednacinePromenljiveStanja = subs(JednacineIzvodaZamene, [lhs(PromenljiveStanjaIzvodi) lhs(pobuda)], [rhs(PromenljiveStanjaIzvodi) rhs(pobuda)])
JednacinePromenljiveStanja = 
promenljiveStanja = [iL1(t), iL2(t), uC(t)]
promenljiveStanja = 
Redukcija reda sistema
[noveJednacine, novePromenljive, Rstruct] = reduceRedundancies(JednacinePromenljiveStanja, promenljiveStanja)
noveJednacine = 
novePromenljive = 
Rstruct = struct with fields:
solvedEquations: [2×1 sym] constantVariables: [2×2 sym] replacedVariables: [0×2 sym] otherEquations: [0×1 sym]
reseneJednacine = Rstruct.solvedEquations
reseneJednacine = 
konstantnePromenljive = Rstruct.constantVariables
konstantnePromenljive = 
zamenjenePromenljive = Rstruct.replacedVariables
zamenjenePromenljive = Empty sym: 0-by-2
drugeJednacine = Rstruct.otherEquations
drugeJednacine = Empty sym: 0-by-1
Resavanje diferencijalne jednacine
odziv_iL1 = dsolve(noveJednacine, iL1(0) == 0, 'IgnoreAnalyticConstraints', false)
odziv_iL1 = 
Napon u(t)
odziv_u = subs(L12*diff(expand(odziv_iL1)), lhs(zamene), rhs(zamene))
odziv_u = 
odziv_u_simp = simplify(odziv_u)
odziv_u_simp = 
vrednosti = [U==1, R==1000, C==1e-6, L==1e-3, a==100]
vrednosti = 
u(t) = subs(odziv_u_simp, lhs(vrednosti), rhs(vrednosti))
u(t) = 
Crtanje grafika
fplot(t, u(t), [0 1e-5])
grid on
xlabel('t')
ylabel('u(t)')